package cn.lijiguo.concurrency.part1.ch05;

import java.util.stream.IntStream;

/**
 * ThreadJoin
 *
 * @author lijiguo
 * @date 2019/12/13 13:18
 */
public class ThreadJoin {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            IntStream.range(1, 100).forEach(i -> {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            });
        });

        Thread t2 = new Thread(() -> {
            IntStream.range(1, 100).forEach(i -> {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            });
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();

        System.out.println("All tasks done.");

        IntStream.range(1, 100).forEach(i -> {
            System.out.println(Thread.currentThread().getName() + ":" + i);
        });
    }
}
